package com.maodou.core.datastore.storage

/**
 * 统一的 KV 存储接口，面向 App 层暴露。
 */
interface KeyValueStorage {
    // 登录状态
    fun setLoggedIn(value: Boolean)
    fun isLoggedIn(): Boolean

    // 通用存储方法
    fun putString(key: String, value: String?)
    fun getString(key: String, defaultValue: String? = null): String?
    
    fun putBoolean(key: String, value: Boolean)
    fun getBoolean(key: String, defaultValue: Boolean = false): Boolean
    
    fun putInt(key: String, value: Int)
    fun getInt(key: String, defaultValue: Int = 0): Int
    
    fun putLong(key: String, value: Long)
    fun getLong(key: String, defaultValue: Long = 0L): Long
    
    fun putFloat(key: String, value: Float)
    fun getFloat(key: String, defaultValue: Float = 0f): Float
    
    fun putDouble(key: String, value: Double)
    fun getDouble(key: String, defaultValue: Double = 0.0): Double
    
    // 对象存储（通过JSON序列化）
    fun <T> putObject(key: String, value: T?, clazz: Class<T>)
    fun <T> getObject(key: String, clazz: Class<T>): T?
    
    // 移除指定key
    fun remove(key: String)
    
    // 检查key是否存在
    fun contains(key: String): Boolean

    // 清空所有 KV（谨慎使用）
    fun clearAll()
}